namespace yiCommerce.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class friendshipgroup : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.FriendShipGroup",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        GroupOwnerId = c.Int(nullable: false),
                        Name = c.String(),
                        MemeberCount = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Customer", t => t.GroupOwnerId, cascadeDelete: true)
                .Index(t => t.GroupOwnerId);
            
            AddColumn("dbo.Customer", "FriendShipGroupId", c => c.Int());
            AddForeignKey("dbo.Customer", "FriendShipGroupId", "dbo.FriendShipGroup", "Id");
            CreateIndex("dbo.Customer", "FriendShipGroupId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.FriendShipGroup", new[] { "GroupOwnerId" });
            DropIndex("dbo.Customer", new[] { "FriendShipGroupId" });
            DropForeignKey("dbo.FriendShipGroup", "GroupOwnerId", "dbo.Customer");
            DropForeignKey("dbo.Customer", "FriendShipGroupId", "dbo.FriendShipGroup");
            DropColumn("dbo.Customer", "FriendShipGroupId");
            DropTable("dbo.FriendShipGroup");
        }
    }
}
